.class final Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice$connectToSocket$1;
.super Ljava/lang/Object;
.source "NmeaBluetoothDevice.kt"

# interfaces
.implements Ljava/lang/Runnable;


# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
    value = Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;->connectToSocket()Z
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x18
    name = null
.end annotation


# instance fields
.field final synthetic this$0:Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;


# direct methods
.method constructor <init>(Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;)V
    .locals 0

    iput-object p1, p0, Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice$connectToSocket$1;->this$0:Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method


# virtual methods
.method public final run()V
    .locals 4

    .line 55
    :try_start_0
    new-instance v0, Ljava/io/InputStreamReader;

    iget-object v1, p0, Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice$connectToSocket$1;->this$0:Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;

    invoke-static {v1}, Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;->access$getInputStream$p(Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;)Ljava/io/InputStream;

    move-result-object v1

    if-eqz v1, :cond_0

    invoke-direct {v0, v1}, Ljava/io/InputStreamReader;-><init>(Ljava/io/InputStream;)V

    .line 56
    new-instance v1, Ljava/io/BufferedReader;

    const/16 v2, 0xc8

    invoke-direct {v1, v0, v2}, Ljava/io/BufferedReader;-><init>(Ljava/io/Reader;I)V

    .line 58
    :goto_0
    iget-object v0, p0, Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice$connectToSocket$1;->this$0:Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;

    invoke-virtual {v0}, Llt/farmis/libraries/externalgps/providers/NMEADeviceManager;->getStatus()Llt/farmis/libraries/externalgps/providers/Status;

    move-result-object v0

    sget-object v2, Llt/farmis/libraries/externalgps/providers/Status;->CONNECTED:Llt/farmis/libraries/externalgps/providers/Status;

    invoke-static {v0, v2}, Lkotlin/jvm/internal/Intrinsics;->areEqual(Ljava/lang/Object;Ljava/lang/Object;)Z

    move-result v0

    if-eqz v0, :cond_2

    iget-object v0, p0, Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice$connectToSocket$1;->this$0:Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;

    invoke-static {v0}, Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;->access$getSocket$p(Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;)Landroid/bluetooth/BluetoothSocket;

    move-result-object v0

    if-eqz v0, :cond_2

    invoke-virtual {v0}, Landroid/bluetooth/BluetoothSocket;->isConnected()Z

    move-result v0

    const/4 v2, 0x1

    if-ne v0, v2, :cond_2

    .line 59
    invoke-virtual {v1}, Ljava/io/BufferedReader;->readLine()Ljava/lang/String;

    move-result-object v0

    .line 60
    iget-object v2, p0, Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice$connectToSocket$1;->this$0:Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;

    const-string v3, "line"

    invoke-static {v0, v3}, Lkotlin/jvm/internal/Intrinsics;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    invoke-virtual {v2, v0}, Llt/farmis/libraries/externalgps/providers/NMEADeviceManager;->setLastMessage(Ljava/lang/String;)V

    goto :goto_0

    .line 55
    :cond_0
    invoke-static {}, Lkotlin/jvm/internal/Intrinsics;->throwNpe()V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_1
    .catch Ljava/lang/NullPointerException; {:try_start_0 .. :try_end_0} :catch_0

    const/4 v0, 0x0

    throw v0

    :catch_0
    move-exception v0

    .line 66
    invoke-virtual {v0}, Ljava/lang/NullPointerException;->printStackTrace()V

    .line 67
    iget-object v0, p0, Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice$connectToSocket$1;->this$0:Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;

    invoke-static {v0}, Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;->access$getDisconnected$p(Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;)Z

    move-result v0

    if-nez v0, :cond_2

    iget-object v0, p0, Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice$connectToSocket$1;->this$0:Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;

    sget-object v1, Llt/farmis/libraries/externalgps/providers/Status;->CONNECTING_FAILED:Llt/farmis/libraries/externalgps/providers/Status;

    invoke-static {v0, v1}, Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;->access$changeStatus(Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;Llt/farmis/libraries/externalgps/providers/Status;)V

    goto :goto_1

    :catch_1
    move-exception v0

    .line 63
    iget-object v1, p0, Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice$connectToSocket$1;->this$0:Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;

    invoke-static {v1}, Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;->access$getDisconnected$p(Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;)Z

    move-result v1

    if-nez v1, :cond_1

    iget-object v1, p0, Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice$connectToSocket$1;->this$0:Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;

    sget-object v2, Llt/farmis/libraries/externalgps/providers/Status;->CONNECTING_FAILED:Llt/farmis/libraries/externalgps/providers/Status;

    invoke-static {v1, v2}, Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;->access$changeStatus(Llt/farmis/libraries/externalgps/providers/bluetooth/NmeaBluetoothDevice;Llt/farmis/libraries/externalgps/providers/Status;)V

    .line 64
    :cond_1
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    :cond_2
    :goto_1
    return-void
.end method
